# pymysql 删除数据
import pymysql


# 修改函数
def update():
    # 连接
    conn = pymysql.connections.Connection(host="127.0.0.1",user="root",passwd="root",db="test",port=3306,charset="utf8")
    # 获取游标对象
    cursor = conn.cursor()
    # 创建sql语句
    sql = "update author set age=300  where authorId=3"
    cursor.execute(sql)
    conn.commit()
    cursor.close()
    conn.close()

# 删除函数
def delete():
    conn = pymysql.connections.Connection(host="127.0.0.1", user="root", passwd="root", db="test", port=3306,charset="utf8")
    cursor = conn.cursor()
    # 创建sql语句
    sql = "delete from author where age = 30"
    cursor.execute(sql)
    conn.commit()
    cursor.close()
    conn.close()
if __name__ == '__main__':
    # update()
    delete()